// JavaScript Document

function sidebarTools(opt_options){ //{toolsText}
  this.opts = opt_options||{};
}

sidebarTools.prototype = new GControl();
sidebarTools.prototype.initialize = function(_map) {
  toolsText = this.opts.toolsText||"Tools";
  openerDiv = createElem("containToolsLabel",toolsText); // open button
  with (openerDiv.style) {
  	borderRight = "1px solid #B0B0B0";
  	borderBottom = "1px solid #B0B0B0";
  	paddingTop = "1px";
  	paddingLeft = "4px";
    textAlign = "left";
    fontSize = "12px";
    fontFamily = "Arial";
    fontWeight = "Bold";
    background = "#FFFFFF";
    backgroundImage = "url('images/down.gif')";
    backgroundRepeat = "no-repeat";
    backgroundPosition = "right";
    width = "80px";
    cursor = "pointer";
  }
  
  itemsDiv = createElem("containToolsIcons");
  with (itemsDiv.style){
    textAlign = "left";
    backgroundColor = "#FFFFFF";
    borderTop = "1px solid black";
    width = "84px";
    height = "100%";
    display = "none";
  }
  
  itemMedicion = createElem();
  with (itemMedicion.style){
    backgroundColor = "#FFFFFF";
    width = "80px";
    paddingLeft = "4px";
    height = "17px";
    cursor = "pointer";
    textAlign = "left";
    fontSize = "12px";
    fontFamily = "Arial";
  }
  itemMedicion.onmouseover = function(){itemMedicion.style.backgroundColor="#FFEEB8";};
  itemMedicion.onmouseout = function(){itemMedicion.style.backgroundColor = "#FFFFFF";};
  itemMedicion.onclick = function(){me.hide(); addToolMedicion();};
  itemMedicion.innerHTML='Medicion';
  
  itemsDiv.appendChild(itemMedicion);
  
  containToolsDiv = createElem("containTools"); 
  containToolsDiv.style.border = "1px solid black";
  containToolsDiv.appendChild(openerDiv);
  containToolsDiv.appendChild(itemsDiv);
  
  _map.getContainer().appendChild(containToolsDiv);
 
  var me = this;
  me.container = itemsDiv;
  me.isVisible = false;
  function openEvent(){me.isVisible=true; GEvent.trigger(me,'open',true)};
  function closeEvent(){me.isVisible=false; GEvent.trigger(me,'close',false)};
  me.show = function(){itemsDiv.style.display = "block"; openerDiv.style.backgroundImage = "url('images/up.gif')"; openEvent();};
  me.hide = function(){itemsDiv.style.display = "none"; openerDiv.style.backgroundImage = "url('images/down.gif')"; closeEvent()};
  openerDiv.onclick = function(){if (me.isVisible) me.hide(); else me.show();};
  return containToolsDiv;
}

sidebarTools.prototype.getDefaultPosition = function() {
  return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(95, 7));
}
